package oop.ex1.orders;

import java.io.File;
/**
 * an order object that compares the files by its Name
 * @author danalmog
 * @author danielshalev
 */
public class FileOrder extends Order {

	/**
	 * compares to files by its Name
	 * @param o1 the first file to compare
	 * @param o2 the second file to compare
	 * @return the order according to absOrder if they are equal, otherwise it returns the remainder between the tow files  
	 */
	@Override
	public int compare(File o1, File o2) {
		if (o1.getName().compareTo(o2.getName())==0)
			//if the files are equal run AbsOrder
			return new AbsOrder().compare(o1, o2);
		return (o1.getName().compareTo(o2.getName()));
	}
	
}
